#列表 list

## 基本操作
[]
list()
[1,2,3]
[1,2,(1,2),[1,2]]
list('abcd')                    #['a', 'b', 'c', 'd']
list(range(-2,3))               #[-2, -1, 0, 1, 2]
list((1,2,3))                   #[1, 2, 3]
list(x+10 for x in range(5))    #[10, 11, 12, 13, 14]

len(list())

[1,2]+["abc"]       #[1, 2, 'abc']
[1,2]*3             #[1, 2, 1, 2, 1, 2]

x=[1,2,(1,2),[1,2]]
for a in x:
    print(a)

2 in [1,2,3]        #True

x=[1,2,[1,2]]
x[0]
x[2]
x[2]=3
x

x=list(range(10))
x                   #[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
x[2:5]
x[:5]
x[2:7:2]
x[7:2:-2]
x[2:5]='abc'
x                   #[0, 1, 'a', 'b', 'c', 5, 6, 7, 8, 9]

x=[[1,2,3],[1,2,3],[1,2,3]]
x[0][0]

## 常用方法
x=[1,2]

x.append('abc')
x                   #[1, 2, 'abc']

x.extend('abc')
x                   #[1, 2, 'abc', 'a', 'b', 'c']   区别同set的add与update一样

x=[1,2,3]
x.insert(1,'abc')
x                   #[1, 'abc', 2, 3]

x=[1,2,2,3]
x.remove(2)
x                   #[1, 2, 3]

x=[1,2,3,4]
x.pop()             #4
x                   #[1, 2, 3]
x.pop(1)            #2
x                   #[1, 3]

x=[1,2,3,4,5,6]
del x[0]
x                   #[2, 3, 4, 5, 6]
del x[2:4]
x                   #[2, 3, 6]
x.clear()
x                   #[]

x=[1,2,3]
y=x.copy()

x=[1,2,3]
x.reverse()
x

x=[4,2,5,2,4,6,3,7]
x.sort()
x
x=['ac','ad','es','AU','BE']
x.sort()
x
x=[1,2,3,'a','b']
x.sort()            #报错，不能混合类型排序
















